package huytq.gs.view;

import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.WakeLockOptions;
import org.andengine.engine.options.resolutionpolicy.FillResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.ui.activity.SimpleLayoutGameActivity;

import com.example.paralletkill.R;

import android.app.Activity;
import android.app.Dialog;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class DangNhap extends SimpleLayoutGameActivity{

	private Activity activity;
	private Dialog dialog;
	
	private static final int WIDTH = 800;
    private static final int HEIGHT = 480;
   
    private Scene _scene;
    private Camera _camera;
    
    public static Sprite sprite;
    VertexBufferObjectManager vbom;
    
    LinearLayout ln_New_DangKy;
    EditText et_user, et_pass;
    TextView tv_thongBao, tv_quenPass;
    ImageView bt_dangNhap, bt_facebook, cb_luuPass;
    
    public DangNhap(Activity activity) {
		this.activity = activity;
		dialog = new Dialog(activity,android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
		dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

		dialog.setCancelable(true);

		dialog.setContentView(R.layout.dangnhap);

		dialog.show();
		this.CreateDangNhap();
	}
	
	@Override
	public EngineOptions onCreateEngineOptions() {
		_camera = new Camera(0, 0, WIDTH, HEIGHT);
        EngineOptions engineOptions = new EngineOptions(true,
                        ScreenOrientation.LANDSCAPE_FIXED, new FillResolutionPolicy(), _camera);
        engineOptions.setWakeLockOptions(WakeLockOptions.SCREEN_ON);
		return engineOptions;
	}

	@Override
	protected void onCreateResources() {
		
		}

	@Override
	protected Scene onCreateScene() {
		_scene = new Scene();
		
		return _scene;
	}

	@Override
	protected int getLayoutID() {
		// TODO Auto-generated method stub
		return R.layout.dangnhap;
	}

	@Override
	protected int getRenderSurfaceViewID() {
		// TODO Auto-generated method stub
		return R.id.andengine_rendersurfaceview;
	}
	
	public void CreateDangNhap(){
		
		this.et_pass = (EditText) dialog.findViewById(R.id.et_pass);
		this.et_user = (EditText) dialog.findViewById(R.id.et_user);
		this.tv_thongBao = (TextView) dialog.findViewById(R.id.tv_thongbao_dangnhap);
		this.tv_quenPass = (TextView) dialog.findViewById(R.id.tv_quenpass);
		this.bt_dangNhap = (ImageView) dialog.findViewById(R.id.bt_dangnhap);
		this.bt_facebook = (ImageView) dialog.findViewById(R.id.bt_facebook);
		this.cb_luuPass = (ImageView) dialog.findViewById(R.id.cb_luupass);
		this.ln_New_DangKy = (LinearLayout) dialog.findViewById(R.id.ln_dangky);
		
		this.ln_New_DangKy.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Log.e("close click", "close click");
				dialog.dismiss();
				runOnUiThread( new Runnable() {
					public void run() {
						DangKy dk = new DangKy(activity);
						dk.CreateDangKy();
					}
				});
				
			}
		});
		
		this.bt_dangNhap.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				dialog.dismiss();
				runOnUiThread(new Runnable() {
					
					@Override
					public void run() {
						// TODO Auto-generated method stub
						new MainMenu(DangNhap.this.activity);
					}
				});
			}
		});
	}
}
